package cn.com.guage.dynamic.datasource.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * 动态的取出我们在切面里设置的数据源的字符串
 *
 * @author yangdechao
 * @version 1.0
 * @date 2020/07/13 15:19
 */
public class DynamicDataSource extends AbstractRoutingDataSource {

	protected final static Logger logger = LoggerFactory.getLogger(DynamicDataSource.class);

	@Override
	protected Object determineCurrentLookupKey() {
		logger.debug("数据源为{}", DatasourceContextHolder.getDB());
		return DatasourceContextHolder.getDB();
	}

}